package cn.david.user.contronller;


import cn.david.basic.exception.BusinessExcepiton;
import cn.david.basic.util.AjaxResult;
import cn.david.user.dto.UserDto;
import cn.david.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;
    @PostMapping("/register/phone")
    public AjaxResult phoneRegister(@RequestBody UserDto userDto) {
        try {
            userService.phoneRegister(userDto);
            return AjaxResult.me();
        } catch (BusinessExcepiton e){
            return AjaxResult.me().setMessage(e.getMessage());

        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage("网络错误");
        }

    }




}
